package com.hushao.aimi.repository;

import com.hushao.aimi.entity.UserRole;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface UserRoleRepository extends JpaRepository<UserRole,String> {


    /**
     * 根据用户id删除其权限
     * @param userId
     * @throws Exception
     */
    @Modifying
    @Query(value = "delete from user_role where user_id=:userId",nativeQuery = true)
    void delByUserId(@Param("userId") String userId)throws Exception;

    /**
     * 根据用户id查询权限
     * @param id
     * @return
     */
    UserRole findByUserId(String id);
}
